<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>充值账户</title>
		<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
		</script>
		<script src="https://unpkg.com/vue@2.6.14/dist/vue.min.js"></script>
	</head>
	<body>
		选择或直接输入要充值得账户
		<div id="xz">
		</div>
		<input id="zh" type="text" placeholder="请输入要充值的账户账号" />
		<button onclick="cz()">确认</button>
	<script>
		$(function(){
			$.ajax({
				url:'mall/zh',
				type:'post',
				dataType:'json',
				success(resp) {
					console.log(resp.code)
					if(resp.code==200)
					{
						var list = resp.data
						for (let i = 0; i < list.length; i++) {
							$("#xz").append("<input  id='"+list[i]+"'  name='accountID' type='radio' value='"+list[i]+"' onclick='xzzh("+list[i]+")' />"+
							"<label for='"+list[i]+"'>"+list[i]+"</label>")
						}
					}
					else{
						alert("没有可充值账户")
					}
				},
				error(e)
				{
					alert("查询后台出错")
				}
			})
		})
		function cz(){
			var zh =$("#zh").val()
			var obj ={
				accountID:zh
			}
			var str = JSON.stringify(obj)
			console.log(zh)
			$.ajax({
				url:'mall/czzh',
				type:'post',
				contentType:'application/json',
				dataType:'json',
				data:str,
				success(resp) {
					console.log(resp.code)
					if(resp.code==200)
					{
						var a =resp.data.account
						console.log(a)
						var accountID=a.accountID
						var theBalanceOf=a.theBalanceOf
						var id= resp.data.orderId
						sessionStorage.setItem("accountID",accountID)
						sessionStorage.setItem("theBalanceOf",theBalanceOf)
						sessionStorage.setItem("orderId",id)
						console.log(id)
						console.log(accountID)
						window.location.replace("czzhxq.html")
					}
					else{
						alert("账号不存在，请检查后重新输入")
					}
				},
				error(e)
				{
					alert("查询后台出错")
				}
				
			})
		}
		function xzzh(zh){
			$("#zh").val(zh)
		}
	</script>
</html>